package com.unistec.fileserver.server.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.unistec.fileserver.client.entity.Resource;

import tk.mybatis.mapper.common.Mapper;

/**
 * 计划任务映射文件 
 * 
 * @description
 * @author 胡晓光
 * @date 2021-9-9
 * @time 17:27:01
 *
 */
public interface ResourceMapper extends Mapper<Resource> {
	/**
	 * 删除存在的任务
	 * 
	 * @description
	 * @author 胡晓光
	 * @date 2021-9-10
	 * @time 10:49:17
	 * 
	 * @param jobGroupId
	 * @param jobId
	 */
	@Delete("delete from resource where upload_finish_time >=(NOW() - interval 24 hour)")
	void deleteResourceOlderThan24Hours();

	/**
	 * 获取超过24小时的临时资源
	 */
	@Select("select * from resource where upload_finish_time >=(NOW() - interval 24 hour)")
	List<Resource> getResourceOlderThan24Hours();

	/**
	 * 通过唯一值查找资源
	 * 
	 * @description
	 * @author 胡晓光
	 * @date 2021-9-30
	 * @time 10:53:16
	 * 
	 * @param unique
	 * @return
	 */
	Resource selectOneByUnique(String unique);
}
